﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    internal class CSharpMethodExample
    {
        public static void Show()
        {
            Calculator calculator = new Calculator();
            Console.WriteLine(calculator.GetCircleArea(10));
            Console.WriteLine(calculator.GetCylinderVolume(10,4));
            Console.WriteLine(calculator.GetConeVolume(10,4));
        }
    }
    /// <summary>
    /// 在这个类中演示了类中为什么需要方法和函数
    /// 目的1：隐藏复杂的逻辑
    /// 目的2：把大的算法分解为小算法
    /// 目的3：复用
    /// </summary>
    class Calculator
    {
        
        public double GetCircleArea(double r)
        {
            return Math.PI * r * r;
        }

        public double GetCylinderVolume(double r, double h)
        {
            //return r * r * h * 3.14;
            return GetCircleArea(r) * h;
        }

        public double GetConeVolume(double r, double h)
        {
            //return 3.14 * r * r * h / 3;
            return GetCylinderVolume(r, h) / 3;
        }

    }
}
